home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include "assert.h"
- #include "system.h"
- #include <sys/types.h>
- #include "emTypes.h"
- #include "sys/file.h"
-
- char assertMessage[] = "Assertion failed: file %s, line %d\n";
- #define FILENAME "/EC/OperationNames/Names"
-
- struct {
- int hashTableSize;
- int hashTableSizeInBytes;
- int charTableMaxSize;
- int charTableCurrentSize;
- OID nextOIDToAllocate;
- OID maxOIDToAllocate;
- } header;
-
- typedef int HashValue;
-
- typedef struct OpNameEntry {
- int offset; /* into charTable of the start of the string */
- OID id; /* what we want */
- } HashTableEntry;
-
- static HashTableEntry *hashTable;
- static char *charTable;
-
- void main()
- {
- int fd, i;
- char filename[256];
- strcpy(filename, EMDIR);
- strcat(filename, FILENAME);
- fd = open(filename, O_RDONLY, 0);
- assert (fd != -1);
- assert(read(fd, &header, sizeof(header)) == sizeof(header));
- hashTable = (HashTableEntry *) malloc(header.hashTableSizeInBytes);
- charTable = malloc(header.charTableMaxSize);
- assert(read(fd, hashTable, header.hashTableSizeInBytes) == header.hashTableSizeInBytes);
- assert(read(fd, charTable, header.charTableMaxSize) == header.charTableMaxSize);
- close(fd);
- fprintf(stdout, "header.hashTableSize:\t%d\n", header.hashTableSize);
- fprintf(stdout, "header.hashTableSizeInBytes:\t%d\n", header.hashTableSizeInBytes);
- fprintf(stdout, "header.charTableMaxSize:\t%d\n", header.charTableMaxSize);
- fprintf(stdout, "header.charTableCurrentSize:\t%d\n", header.charTableCurrentSize);
- fprintf(stdout, "header.nextOIDToAllocate:\t%x\n", header.nextOIDToAllocate);
- fprintf(stdout, "header.maxOIDToAllocate:\t%x\n", header.maxOIDToAllocate);
- for (i = 0; i < header.hashTableSize; i++) {
- if (hashTable[i].id != 0) {
- fprintf(stdout, "\"%s\" -> 0x%x\n",
- charTable + hashTable[i].offset,
- hashTable[i].id);
- }
- }
- }
-